package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.property.PropertyAddBankCardDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyBankManageGetPageDTO;
import com.itlong.cloud.POJO.VO.property.BankCardInfoVO;
import com.itlong.cloud.POJO.VO.property.PropertyBankManageGetPageVO;
import com.itlong.cloud.paymenthub.IPropertyBankCardManageServiceClient;
import com.itlong.cloud.property.service.IPropertyBankCardManageService;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      物业银行卡管理暴露接口实现类
 * </desc>
 *
 * @createDate 2018/09/20
 */
@RestController
public class PropertyBankCardManageServiceResource implements IPropertyBankCardManageServiceClient{
    @Autowired
    IPropertyBankCardManageService iPropertyBankCardManageService;

    /**
     * <desc>
     *      添加时获取物业银行手机号及支付密码信息
     * <desc/>
     *
     * @param  projectId
     * @return
     * @author Jiaqi.X
     * @createDate 2018/09/20
     */
    @PostMapping(path = "/property/system/bankCard/getBankPayConf")
    @Override
    public Map<String, Object> getBankPayConf(@RequestParam("projectId") String projectId) {
        return iPropertyBankCardManageService.getBankPayConf(projectId);
    }

    /**
     * <desc>
     *      验证银行账户唯一性
     * </desc>
     *
     * @param bankCardNo 银行卡号
     * @return
     * @author Jiaqi.X
     * @createDate 2018/09/20
     */
    @PostMapping(path = "/property/system/bankCard/checkBankCardOnly")
    @Override
    public Integer checkBankCardOnly(@RequestParam("bankCardNo") String bankCardNo,@RequestParam("bankCardId") String bankCardId) {
        return iPropertyBankCardManageService.checkBankCardOnly(bankCardNo,bankCardId);
    }

    /**
     * <desc>
     *      删除银行卡
     * </desc>
     *
     * @param bankCardId
     * @return
     * @author Jiaqi.X
     * @createDate 2018/09/20
     */
    @PostMapping(path = "/property/system/bankCard/deleteBankCard")
    @Override
    public Integer deleteBankCard(@RequestParam("bankCardId") String bankCardId) {
        return iPropertyBankCardManageService.deleteBankCard(bankCardId);
    }

    /**
     * <desc>
     *      获取银行卡账号详情
     * </desc>
     *
     * @param bankCardId
     * @return
     * @author Jiaqi.X
     * @createDate 2018/09/20
     */
    @PostMapping(path = "/property/system/bankCard/getBankCardInfo")
    @Override
    public BankCardInfoVO getBankCardInfo(@RequestParam("bankCardId") String bankCardId) {
        return iPropertyBankCardManageService.getBankCardInfo(bankCardId);
    }

    /**
     * <desc>
     *      查询项目下是否绑定手机号
     * </desc>
     *
     * @param projectId
     * @return
     * @author Jiaqi.X
     * @createDate 2018/09/20
     */
    @PostMapping(path = "/property/system/bankCard/getProjectBankPhone")
    @Override
    public String getProjectBankPhone(@RequestParam("projectId") String projectId) {
        return iPropertyBankCardManageService.getProjectBankPhone(projectId);
    }

    /**
     * <desc>
     *      添加银行卡
     * </desc>
     *
     * @param propertyAddBankCardDTO
     * @return
     * @author Jiaqi.X
     * @createDate 2018/09/20
     */
    @PostMapping(path = "/property/system/bankCard/addBankCard")
    @Override
    public String addBankCard(@RequestBody PropertyAddBankCardDTO propertyAddBankCardDTO) throws Exception {
        return iPropertyBankCardManageService.addBankCard(propertyAddBankCardDTO);
    }

    /**
     * <desc>
     *     获取抄银行卡账户列表
     * </desc>
     *
     * @param pageDTO   参数DTO
     * @return
     * @author Jiaqi.X
     * @createDate 2018/09/21
     */
    @PostMapping(path = "/property/system/bankCard/getPage")
    @Override
    public Page<PropertyBankManageGetPageVO> getPage(@RequestBody PropertyBankManageGetPageDTO pageDTO) throws Exception {
        return iPropertyBankCardManageService.getPage(pageDTO);
    }

    /**
     * <desc>
     *      获取银行名称
     * </desc>
     *
     * @param bankName
     * @return
     * @author Jiaqi.X
     * @createDate 2018/09/27
     */
    @PostMapping(path = "/property/system/bankCard/getBanks")
    @Override
    public List<Map<String,Object>> getBanks(@RequestParam("bankName") String bankName){
        return iPropertyBankCardManageService.getBanks(bankName);
    }

    /**
     * <desc>
     *      获取物业银行卡列表
     * </desc>
     *
     * @param projectId
     * @return
     * @author Jiaqi.X
     * @createDate 2018/09/27
     */
    @PostMapping(path = "/property/system/bankCard/getBankCards")
    @Override
    public List<Map<String,Object>> getBankCards(@RequestParam("projectId") String projectId){
        return iPropertyBankCardManageService.getBankCards(projectId);
    }
}
